//
//  BitArray.h
//  SimulacraDB
//
//  Created by Andre Cohen on 8/9/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface ByteArray : NSObject {
	NSMutableArray *data;
}

+ (ByteArray *)createFromInt:(int)val;
+ (ByteArray *)createFromFloat:(double)val;
+ (ByteArray *)createFromString:(NSString *)string;
+ (ByteArray *)createWithSize:(int)size;

- (id)initWithData:(char *)raw length:(int)len;
- (id)initWithString:(NSString *)string;
- (id)initWithNSData:(NSData *)raw;

- (char)getBitFromLocation:(int)loc;
- (char)getCharFromLocation:(int)loc;
- (int)getIntFromLocation:(int)loc;
- (double)getFloatFromLocation:(int)loc;
- (NSString *)getStringFromLocation:(int)loc length:(int)len;

- (void)setBitAtLocation:(int)loc value:(BOOL)val;
- (void)setCharAtLocation:(int)loc value:(char)val;
- (void)setIntAtLocation:(int)loc value:(int)val;
- (void)setStringAtLocation:(int)loc value:(NSString *)val;

- (NSString *)toString;
- (NSData *)toNSData;

- (NSArray *)toArray:(char)val;
- (char)fromArray:(NSArray *)array;

- (int)appendChar:(char)value;
- (int)appendInt:(int)value;
- (double)appendFloat:(double)value;
- (int)appendString:(NSString *)value;
- (int)appendByteArray:(ByteArray *)value;

- (char)extractCharFromLocation:(int)loc;
- (int)extractIntFromLocation:(int)loc;
- (NSString *)extractStringFromLocation:(int)loc length:(int)len;

- (bool)extractFrom:(int)loc length:(int)len;

- (int)count;
- (int)bitCount;

- (NSString *)description;
- (NSString *)bitDescription;

@end
